package com.xtoad.ecms.baseinfo.model;

import com.xtoad.ecms.baseinfo.enums.ElementType;
import com.xtoad.ecms.common.web.base.BaseModel;
import org.hibernate.annotations.Table;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

/**
 * 页面元素
 *
 * @author xtoad
 * @date 2021/1/13
 */
@Entity
@Table(appliesTo = "page_element", comment = "页面元素表")
public class PageElement extends BaseModel {

    /**
     * 元素类型
     */
    @Column(nullable = false, columnDefinition = "varchar(10) comment '元素类型'")
    @Enumerated(EnumType.STRING)
    private ElementType type;

    /**
     * 标题
     */
    @Column(nullable = false, columnDefinition = "varchar(50) comment '标题'")
    private String title;

    /**
     * 所属页面
     */
    @ManyToOne
    @JoinColumn(nullable = false, columnDefinition = "comment '所属页面'")
    private WebPage page;


    /**
     * 获取 元素类型
     */
    public ElementType getType() {
        return this.type;
    }

    /**
     * 设置 元素类型
     */
    public void setType(ElementType type) {
        this.type = type;
    }

    /**
     * 获取 标题
     */
    public String getTitle() {
        return this.title;
    }

    /**
     * 设置 标题
     */
    public void setTitle(String title) {
        this.title = title;
    }

    /**
     * 获取 所属页面
     */
    public WebPage getPage() {
        return this.page;
    }

    /**
     * 设置 所属页面
     */
    public void setPage(WebPage page) {
        this.page = page;
    }

    @Override
    public String toString() {
        return "PageElement{" +
                "type=" + type +
                ", title='" + title + '\'' +
                ", page=" + page +
                "} " + super.toString();
    }
}
